package figure8;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.TargetDataLine;

public class InputMixer {
	private String name;
	private Mixer mixer;
	private AudioFormat format;
	
	private DataLine.Info info;
	
	public InputMixer(String name, Mixer mixer, AudioFormat format) {
		this.name = name;
		this.mixer = mixer;
		this.format = format;
		
		this.info = new DataLine.Info(TargetDataLine.class, format);
	}
	
	public String getName() {
		return name;
	}
	
	public Mixer getMixer() {
		return mixer;
	}

	public AudioFormat getFormat() {
		return format;
	}
	
	public TargetDataLine dataLine() throws LineUnavailableException {
		return (TargetDataLine) this.mixer.getLine(this.info);
	}
	
	public String toString() {
		return name;
	}
}
